<template>
<div :id="$attrs.id" style="width: 100%; height:300px"></div>
</template>
<script>
import * as echarts from 'echarts';
export default {
  name: "lineEchart",
  data(){
    return{

    }
  },
  mounted() {
    this.$nextTick(()=>{
      this.getLine();
    })
  },
  methods:{
    getLine(){
      var chartDom = document.getElementById(this.$attrs.id);
      var myChart = echarts.init(chartDom);
      var option;
      let legendData=[];
      this.$attrs.lineYDataList.forEach(item=>{
        legendData.push(item.name);
      })
      option = {
        legend: {
          data: legendData
        },
        grid: {
          left: '2%',
          right: '3%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.$attrs.lineXDataList,
        },
        yAxis: {
          type: 'value'
        },
        series:this.$attrs.lineYDataList
      };

      option && myChart.setOption(option);
    },
  },
}
</script>

<style scoped lang="scss">

</style>
